package com.battle.service.repository.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.battle.pojo.entity.PersonOrganizationMp;
import com.battle.pojo.entity.UserOrganizationMp;
import com.battle.service.mapper.PersonOrganizationMpMapper;
import com.battle.service.mapper.UserOrganizationMpMapper;
import com.battle.service.repository.in.PersonOrganizationMpRepository;
import com.battle.service.repository.in.UserOrganizationMpRepository;
import lombok.AllArgsConstructor;
import nirvana.core.repository.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@AllArgsConstructor
public class PersonOrganizationMpRepositoryImpl extends Repository<PersonOrganizationMpMapper, PersonOrganizationMp> implements PersonOrganizationMpRepository {
    final PersonOrganizationMpMapper mapper;

    @Override
    public List<PersonOrganizationMp> selectByOrganizationId(Long organizationId, Long userId) {
        return mapper.selectList(new LambdaQueryWrapper<>(new PersonOrganizationMp())
                .eq(ObjectUtil.isNotNull(organizationId),PersonOrganizationMp::getOrganizationId, organizationId)
                .eq(ObjectUtil.isNotNull(userId),PersonOrganizationMp::getPersonId, userId)
                .eq(PersonOrganizationMp::getIsDelete, 0));
    }
}
